package leetcode_core.leetcode_1;

public class Jump {
    public int jump(int[] nums) {
        int jumps = 0;
        int start = 0,end = 0;
        //定义跳跃索引区间[start,end]
        while (end < nums.length-1) {
            //一旦大于等于了，就证明找到了
            int maxPos = Integer.MIN_VALUE;
            for(int i = start;i<=end;i++){
                maxPos = Math.max(maxPos,nums[i]+i);
            }
            start = end+1;
            end = maxPos;
            jumps++;
        }
        return jumps;
    }
}
